import type { RouteRecordRaw } from 'vue-router';

import { $t } from '@/locales';
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@/constants';
import { Layout } from '@/layouts';

/** 全局404页面 */
const fallbackNotFoundRoute: RouteRecordRaw = {
  component: () => import('@/views/fallback/not-found.vue'),
  meta: {
    hideInBreadcrumb: true,
    hideInMenu: true,
    hideInTab: true,
    title: '404',
  },
  name: 'FallbackNotFound',
  path: '/:path(.*)*',
};

// 白名单放行路由
const whiteListRoutes: RouteRecordRaw[] = [
  {
    path: '/auth',
    name: 'Authorization',
    redirect: LOGIN_PATH,
    children: [
      {
        name: 'Login',
        path: 'login',
        component: () => import('@/views/login/index.vue'),
        meta: {
          title: $t('page.auth.login'),
        },
      },
    ],
  },
];

// 全局路由
const defaultRoutes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'Base',
    redirect: DEFAULT_HOME_PATH,
    component: Layout,
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        meta: {
          icon: 'mdi:view-dashboard-outline',
          title: 'menu.dashboard',
        },
        component: () => import('@/views/dashboard/index.vue'),
      },
    ],
  },
];

export { defaultRoutes, whiteListRoutes, fallbackNotFoundRoute };
